<template>
  <div class="content">
    <div class="account_main">
      <i class="el-icon-s-custom" style="float: left"></i>
      <div style="float: left; margin-top: 8px; margin-left: 12px">
        <span class="title">我的等级：</span
        ><span class="title">{{ accountInfo.role_name }}</span
        ><span class="sub_title"
          >（{{ accountInfo.is_partner ? "主账号" : "子账号" }}）</span
        >
      </div>
    </div>
    <div class="areas">
      <div v-for="(item, index) in accountInfo.areas" class="area" :key="index">
        <span>{{ index + 1 }}</span>
        {{ item.province }}-{{ item.city }}-{{ item.region }}
      </div>
    </div>
    <div class="account_main">
      <i class="el-icon-s-custom" style="float: left"></i>
      <div style="float: left; margin-top: 8px; margin-left: 12px">
        <span class="title">我的账户信息：</span>
      </div>
    </div>
    <div class="account_info">
      <div class="first_account_info">
        <span class="account_prop"
          >姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</span
        ><span>{{ accountInfo.nickName }}</span>
      </div>
      <div class="first_account_info">
        <span class="account_prop">登陆账号</span
        ><span>{{ accountInfo.username }}</span>
      </div>
      <div class="first_account_info">
        <span class="account_prop">手机号码</span
        ><span>{{ accountInfo.mobile }}</span>
      </div>
      <div class="btns">
        <el-button class="btn" type="primary" @click="showEditAccountInfo = true"
          >修改</el-button
        >
        
      </div>
    </div>

    <jdialog
      title="账号信息编辑"
      :visible.sync="showEditAccountInfo"
      width="640px"
    >
      <div style="padding: 20px">
        <div style="margin-bottom: 20px">
          <span style="color: red; margin-right: 4px">*</span
          ><span style="margin-right: 20px"> 登陆账号</span
          ><el-input
            :placeholder="accountInfo.mobile"
            size="small"
            style="width: 360px"
            disabled
          ></el-input>
        </div>
        <div style="margin-bottom: 20px">
          <span style="color: red; margin-right: 4px">*</span
          ><span style="margin-right: 20px">姓名/名称</span
          ><el-input
            placeholder="请填写姓名"
            size="small"
            style="width: 360px"
            v-model="accountInfo.nickName"
          ></el-input>
        </div>
        <div style="margin-bottom: 20px">
          <span style="color: red; margin-right: 4px">*</span
          ><span style="margin-right: 20px">手机号</span
          ><el-input
            placeholder="请填写姓名"
            size="small"
            style="width: 360px"
            v-model="accountInfo.mobile"
          ></el-input>
        </div>
        <div style="margin-bottom: 20px">
          <span style="color: red; margin-right: 4px">*</span
          ><span style="margin-right: 20px">Email</span
          ><el-input
            placeholder="请填写Email"
            size="emall"
            style="width: 360px"
            v-model="accountInfo.email"
          ></el-input>
        </div>
        <div style="margin-bottom: 20px">
          <span style="color: red; margin-right: 4px">*</span
          ><span style="margin-right: 20px">密码</span
          ><el-input
            placeholder="请填写密码(不改请留空)"
            size="small"
            style="width: 360px"
            v-model="accountInfo.password"
          ></el-input>
        </div>
      </div>
      <div style="text-align: center; padding: 20px">
        <el-button size="mini" type="primary" @click="certainModify"
          >确定</el-button
        >
        <el-button size="mini" @click="showEditAccountInfo = false">取消</el-button>
      </div>
    </jdialog>
  </div>
</template>

<script>
import { getAccountInfo, adminUpdate } from "@/api/member";
export default {
  data() {
    return {
      accountInfo: {},
      showEditAccountInfo: false,
      form: {
        nickName: "",
        email: "",
        password: "",
      },
    };
  },
  created() {
    //获取账号信息
  },
  mounted() {
    this.getAccountInfo();
  },
  methods: {
    getAccountInfo() {
      getAccountInfo(sessionStorage.getItem("LOGIN_USERNAME_id")).then(
        (res) => {
          if (res.code === 200) {
            res.data.role_name = res.data.role_name || "合伙人";
            res.data.areas = res.data.areas || [];
            this.accountInfo = res.data;
            this.accountInfo.password = ""
          } else {
            this.$message(res.message);
          }
        }
      );
    },
    // 新增
    certainModify() {
  
          if (this.form.serviceManager) {
            if (!this.form.memberId) {
              this.$message.error("请输入绑定会员id");
              return false;
            }
          }
      
            adminUpdate(this.accountInfo).then((res) => {
              console.log(res);
              if (res.code === 200) {
                this.$message.success("修改成功");

                this.showEditAccountInfo = false;
              } else {
                this.$message.error(res.message);
              }
            });
        
      
    },
  },
};
</script>

<style lang="scss" scoped>
.content {
  padding: 40px 40px;
  background-color: #fff;
  height: 100%;
  .title {
    font-size: 16px;
    font-weight: 700;
    color: #333;
  }
  .areas {
    display: flex;
    margin-bottom: 20px;
    .area {
      width: 300px;
      border: 1px solid #ccc;
      border-radius: 2px;
      height: 40px;
      padding-left: 10px;
      display: flex;
      align-items: center;
      margin-left: 20px;
      span {
        display: inline-block;
        background-color: #333;
        height: 25px;
        width: 25px;
        border-radius: 50%;
        margin-right: 10px;
        color: #fff;
        text-align: center;
        line-height: 25px;
      }
    }
  }
  .account_main {
    margin-bottom: 60px;
    height: 40px;
    &:first-of-type {
      margin-bottom: 20px;
    }
  }
  .sub_title {
    font-size: 12px;
    color: #999;
    margin-left: 12px;
  }
  .account_info {
    margin-top: -20px;
    margin-left: 48px;
    .first_account_info {
      margin: 10px 0;
    }
    .account_prop {
      color: #999;
      margin-right: 40px;
    }
  }
  .el-icon-s-custom {
    color: white;
    background-color: #666;
    font-size: 36px;
  }
}
</style>
